<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="structpage/templates/defaultLayoutadmin.xhtml">
        <ui:define name="title">
            <h:outputText value="ChequeTeatinos" />
        </ui:define>
        
        <ui:define name="scriptmenu">
            <script>
                $(document).ready(function() {
                    selectandtitleadmin("#liofertas", "ChequeTeatinos - Ofertas"); 
                });
            </script>               
        </ui:define>
    
        <ui:define name="content">
            <!-- Añadir o eliminar oferta -->
            <br></br>
            <h5>
                <a href="addofferadmin.jsf">
                    <input class="botones" type="button" value="#{msg.newOffer}" />
                </a>
            </h5>
            <h:form>
                <p:panel id="panel" style="none"> 
                    <p:messages id="messages" />
                    <p:dataTable id="offers" var="offer" value="#{ofertasAdminBean.ofertas}" rowKey="#{car.model}">

                        <p:column headerText="#{msg.offer}">
                            #{offer.nombreOferta}
                        </p:column>

                        <p:column headerText="#{msg.originalprice}">
                            #{offer.precioOriginal}
                        </p:column>

                        <p:column headerText="#{msg.offeredprice}">
                            #{offer.precioConOferta}
                        </p:column>

                        <p:column headerText="#{msg.companie}">
                            #{offer.empresa.nombre}
                        </p:column>


                        <p:column style="width:4%">
                            <p:commandButton id="viewButton" value="#{msg.delete}" icon="ui-icon-trash" action="#{ofertasAdminBean.deleteOffer()}" oncomplete="window.location.reload()">
                                <f:setPropertyActionListener value="#{offer}" target="#{ofertasAdminBean.selectedOffer}" />
                            </p:commandButton>
                        </p:column>                    

                    </p:dataTable>                
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

